<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>BabyOS: test_fifo.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="2.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">BabyOS
   &#160;<span id="projectnumber">V1.1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_b9223522bb56aee4ab59f7ba381d2163.html">bos</a></li><li class="navelem"><a class="el" href="dir_f2a2cc749b6bfcea90db6730434b0bd6.html">core</a></li><li class="navelem"><a class="el" href="dir_376a7dcbd1f9af36f126855cda4c2eb7.html">test</a></li><li class="navelem"><a class="el" href="dir_77188c236e9c725112fc4dd232c99e45.html">fifo</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">test_fifo.c</div>  </div>
</div><!--header-->
<div class="contents">
<a href="test__fifo_8c.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#include &lt;stdio.h&gt;</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="b__fifo_8h.html">b_fifo.h</a>&quot;</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;</div><div class="line"><a name="l00005"></a><span class="lineno"><a class="line" href="test__fifo_8c.html#a7993144253291a058ae75ef865f69260">    5</a></span>&#160;uint8_t <a class="code" href="test__fifo_8c.html#a7993144253291a058ae75ef865f69260">fifo_buf</a>[1024];</div><div class="line"><a name="l00006"></a><span class="lineno"><a class="line" href="test__fifo_8c.html#a2ccc9abe2688b6b031fca9081c5ee88a">    6</a></span>&#160;uint8_t <a class="code" href="test__fifo_8c.html#a2ccc9abe2688b6b031fca9081c5ee88a">test_buf</a>[32];</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;</div><div class="line"><a name="l00008"></a><span class="lineno"><a class="line" href="test__fifo_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4">    8</a></span>&#160;<span class="keywordtype">int</span> <a class="code" href="test__fifo_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a>()</div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;{</div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;    <span class="keywordtype">int</span> type, val;</div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;    printf(<span class="stringliteral">&quot;hello\r\n&quot;</span>);</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;    <span class="keywordtype">int</span> fifo_no = <a class="code" href="group___f_i_f_o___exported___functions.html#ga8b9d241884018d7286093f4759053159">bFIFO_Regist</a>(<a class="code" href="test__fifo_8c.html#a7993144253291a058ae75ef865f69260">fifo_buf</a>, 1024);</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;    printf(<span class="stringliteral">&quot;regist fifo_no:%d\r\n&quot;</span>,fifo_no);</div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;    <span class="keywordflow">while</span>(1)</div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;    {</div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;        scanf(<span class="stringliteral">&quot;%d %d&quot;</span>,&amp;type, &amp;val );</div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;        printf(<span class="stringliteral">&quot;t:%d num:%d\r\n&quot;</span>, type, val);</div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;        <span class="keywordflow">if</span>(type)</div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;    {</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;            val = (val &lt;= 11) ? val : 11;</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;            <a class="code" href="group___f_i_f_o___exported___functions.html#ga4aac823c61f21ceac467618edb17b27b">bFIFO_Write</a>(fifo_no, <span class="stringliteral">&quot;hello world&quot;</span>, val);</div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;           <span class="keywordflow">if</span>(val &lt; 0)</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;       {</div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;               printf(<span class="stringliteral">&quot;write error \r\n&quot;</span>);</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;           <span class="keywordflow">continue</span>;</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;           }</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;        }</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;    <span class="keywordflow">else</span></div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;    {</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;       val =  <a class="code" href="group___f_i_f_o___exported___functions.html#ga5cb3e1921484b7ecaed70dc77e30c26e">bFIFO_Read</a>(fifo_no, <a class="code" href="test__fifo_8c.html#a2ccc9abe2688b6b031fca9081c5ee88a">test_buf</a>, val);</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;           <span class="keywordflow">if</span>(val &lt; 0)</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;       {</div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;               printf(<span class="stringliteral">&quot;read error \r\n&quot;</span>);</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;           <span class="keywordflow">continue</span>;</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;           }</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;       <a class="code" href="test__fifo_8c.html#a2ccc9abe2688b6b031fca9081c5ee88a">test_buf</a>[val] = 0;</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;           printf(<span class="stringliteral">&quot;%d s:%s\r\n&quot;</span>, val, <a class="code" href="test__fifo_8c.html#a2ccc9abe2688b6b031fca9081c5ee88a">test_buf</a>);</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;        }</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;        uint16_t f_len;</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;        <a class="code" href="group___f_i_f_o___exported___functions.html#ga41d34a28dbae41e482bcbf241caeb899">bFIFO_Length</a>(fifo_no, &amp;f_len);</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;        printf(<span class="stringliteral">&quot;len:%d\r\n&quot;</span>, f_len);</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    }</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;}</div><div class="ttc" id="group___f_i_f_o___exported___functions_html_ga4aac823c61f21ceac467618edb17b27b"><div class="ttname"><a href="group___f_i_f_o___exported___functions.html#ga4aac823c61f21ceac467618edb17b27b">bFIFO_Write</a></div><div class="ttdeci">int bFIFO_Write(int no, uint8_t *pbuf, uint16_t size)</div></div>
<div class="ttc" id="group___f_i_f_o___exported___functions_html_ga41d34a28dbae41e482bcbf241caeb899"><div class="ttname"><a href="group___f_i_f_o___exported___functions.html#ga41d34a28dbae41e482bcbf241caeb899">bFIFO_Length</a></div><div class="ttdeci">int bFIFO_Length(int no, uint16_t *plen)</div></div>
<div class="ttc" id="group___f_i_f_o___exported___functions_html_ga5cb3e1921484b7ecaed70dc77e30c26e"><div class="ttname"><a href="group___f_i_f_o___exported___functions.html#ga5cb3e1921484b7ecaed70dc77e30c26e">bFIFO_Read</a></div><div class="ttdeci">int bFIFO_Read(int no, uint8_t *pbuf, uint16_t size)</div></div>
<div class="ttc" id="test__fifo_8c_html_ae66f6b31b5ad750f1fe042a706a4e3d4"><div class="ttname"><a href="test__fifo_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a></div><div class="ttdeci">int main()</div><div class="ttdef"><b>Definition:</b> <a href="test__fifo_8c_source.html#l00008">test_fifo.c:8</a></div></div>
<div class="ttc" id="test__fifo_8c_html_a7993144253291a058ae75ef865f69260"><div class="ttname"><a href="test__fifo_8c.html#a7993144253291a058ae75ef865f69260">fifo_buf</a></div><div class="ttdeci">uint8_t fifo_buf[1024]</div><div class="ttdef"><b>Definition:</b> <a href="test__fifo_8c_source.html#l00005">test_fifo.c:5</a></div></div>
<div class="ttc" id="group___f_i_f_o___exported___functions_html_ga8b9d241884018d7286093f4759053159"><div class="ttname"><a href="group___f_i_f_o___exported___functions.html#ga8b9d241884018d7286093f4759053159">bFIFO_Regist</a></div><div class="ttdeci">int bFIFO_Regist(uint8_t *pbuf, uint16_t size)</div></div>
<div class="ttc" id="test__fifo_8c_html_a2ccc9abe2688b6b031fca9081c5ee88a"><div class="ttname"><a href="test__fifo_8c.html#a2ccc9abe2688b6b031fca9081c5ee88a">test_buf</a></div><div class="ttdeci">uint8_t test_buf[32]</div><div class="ttdef"><b>Definition:</b> <a href="test__fifo_8c_source.html#l00006">test_fifo.c:6</a></div></div>
<div class="ttc" id="b__fifo_8h_html"><div class="ttname"><a href="b__fifo_8h.html">b_fifo.h</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.14
</small></address>
</body>
</html>
